package Demo5;

import java.util.Scanner;

public class Main7 {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t=new Thread(()->{

                try {
                    Thread.sleep(1000);
                    System.out.println("wait之前");
                    synchronized(lock) {
                        lock.wait();
                    }
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("wait之后");

        });

       Thread t1=new Thread(()->{
           Scanner in=new Scanner(System.in);
           System.out.println("请输入任意内容：");
           in.nextInt();
           synchronized (lock){
               lock.notify();
           }
       });

    t.start();
    t1.start();
    }
}
